from flask import Flask, request, jsonify
from prediction import predict_fraud
import joblib

app = Flask(__name__)

@app.route('/predict', methods=['POST'])
def predict():
    """欺诈预测API接口"""
    try:
        data = request.json
        result = predict_fraud(data)
        return jsonify(result)
    except Exception as e:
        return jsonify({'error': str(e)}), 400

if __name__ == '__main__':
    # 启动服务
    app.run(host='0.0.0.0', port=5000, debug=True)